package com.hl.web;

import com.hl.pojo.Users;
import com.hl.service.ChangePasswordService;
import com.hl.util.GeneralResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/change")
public class ChangePasswordController {
    @Autowired
    private ChangePasswordService changePasswordService;
    @RequestMapping("/changePassword")
    public GeneralResult changePassword(@RequestBody Map<String,Object> map){
        Integer Id = (Integer) map.get("userId");
        String pas = (String) map.get("password");
        System.out.println(pas);
        System.out.println(Id);
        Users users = new Users();
        int num = changePasswordService.changePassword(pas,Id);
        if (num == 0){
            return GeneralResult.fail();
        }else{
            return GeneralResult.success("请求成功",num);
        }

    }
    @RequestMapping("/changePassword1")
    public GeneralResult SelectUsersAll(@RequestBody Map<String,Integer> map){
        Integer id = map.get("userId");
        List<Users> list = changePasswordService.SelectUsersAll(id);
        return GeneralResult.success(list);
    }
}
